﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string url = "http://localhost:4224/feedbackfetch/HTMLPage.htm"; //"http://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback2&userid=kplusc_gift&ftab=FeedbackAsSeller";
        Common c = new Common();

        //"(?<=<div\\s*id=\"enText\"\\s*style=\"display:block\">).*?(?=</div>)"
        string htmlContent = c.getHTML(url);
        string feedContent = c.GetData("(?<=<table\\s*border=\"0\"\\s*cellpadding=\"0\"\\s*cellspacing=\"0\"\\s*width=\"100%\"\\s*class=\"FbOuterYukon\").+(?=</table>)", htmlContent);
        //  Response.Write(c.GetData("(?<=<span\\s*class=\"mbg-nw\">).+(?=</table>)", htmlContent)[0].ToString());

        List<string> clist = c.GetListData("(?<=<tr class=\"bot\"><td>&nbsp;</td><td>).*?(?=</td><td id=\"viewItemId\">)", feedContent);

        List<string> plist = new List<string>();
        List<string> itmlist = new List<string>();
        List<string> itmNamlist = new List<string>();

        List<string> namelist = c.GetListData("(?<=<span\\s*class=\"mbg-nw\">).*?(?=</span>)", feedContent);
        //   List<string> itemlist = c.GetData("(?<=<td id=\"viewItemId\"><a href=\").*?(?=\">)", htmlContent);

        //for (int i = 0; i < namelist.Count; i++)
        //{
        //    Response.Write(namelist[i] + "<br>");
        //}


        for (int i = 0; i < clist.Count; i++)
        {
            // string[] sa = clist[i].Split("</td><td>");
            plist.Add(clist[i].Substring(clist[i].IndexOf("</td><td>") + 9));
            if (clist[i].IndexOf("(#") > 0)
            {
                itmlist.Add(clist[i].Substring(clist[i].IndexOf("(#") + 2, 12));
                itmNamlist.Add(clist[i].Substring(0, clist[i].IndexOf("(#")));
            }
            else
            {
                itmlist.Add("--");
                itmNamlist.Add("--");
            }

            Response.Write(namelist[i] + plist[i] + itmNamlist[i] + itmlist[i] + "<br>");
        }
        string pageContent = c.GetData("(?<=<span>of).*?(?=</span>)", htmlContent);


        Response.Write(pageContent + "<br>");
        //class="FbOuterYukon"

        //itemsPerPageTab

        //PTD_pagination1
    }
}